﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomControls.ImageButton
{
    /// <summary>
    /// ImageButtonSelect.xaml 的交互逻辑
    /// </summary>
    public partial class ImageButtonSelect : UserControl
    {
        public ImageButtonSelect()
        {
            InitializeComponent();
            this.button.Click += Button_Click;
        }

        /// <summary>
        /// 点击时
        /// </summary>
        public event EventHandler Click;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            this.Click?.Invoke(this, new EventArgs());
        }

        #region NormalImageUri

        /// <summary>
        /// 获取或设置默认图片Uri
        /// </summary>
        public ImageSource NormalImageUri
        {
            get { return (ImageSource)GetValue(NormalImageUriProperty); }
            set { SetValue(NormalImageUriProperty, value); }
        }

        public static readonly DependencyProperty NormalImageUriProperty =
            DependencyProperty.Register("NormalImageUri", typeof(ImageSource), typeof(ImageButtonSelect), new PropertyMetadata(null));

        #endregion

        #region DisableImageUri

        /// <summary>
        /// 获取或设置按钮不可用时的图片Uri
        /// </summary>
        public ImageSource DisableImageUri
        {
            get { return (ImageSource)GetValue(DisableImageUriProperty); }
            set { SetValue(DisableImageUriProperty, value); }
        }

        public static readonly DependencyProperty DisableImageUriProperty =
            DependencyProperty.Register("DisableImageUri", typeof(ImageSource), typeof(ImageButtonSelect), new PropertyMetadata(null));

        #endregion

        #region DownImageUri

        /// <summary>
        /// 获取或设置按键按下时的图片Uri
        /// </summary>
        public ImageSource DownImageUri
        {
            get { return (ImageSource)GetValue(DownImageUriProperty); }
            set { SetValue(DownImageUriProperty, value); }
        }

        public static readonly DependencyProperty DownImageUriProperty =
            DependencyProperty.Register("DownImageUri", typeof(ImageSource), typeof(ImageButtonSelect), new PropertyMetadata(null));

        #endregion

        #region OverImageUri

        /// <summary>
        /// 获取或设置鼠标越过时的图片Uri
        /// </summary>
        public ImageSource OverImageUri
        {
            get { return (ImageSource)GetValue(OverImageUriProperty); }
            set { SetValue(OverImageUriProperty, value); }
        }

        public static readonly DependencyProperty OverImageUriProperty =
            DependencyProperty.Register("OverImageUri", typeof(ImageSource), typeof(ImageButtonSelect), new PropertyMetadata(null));


        #endregion

        #region IsToDoSelect

        /// <summary>
        /// 获取或设置鼠标越过时的图片Uri
        /// </summary>
        public bool IsToDoSelect
        {
            get { return (bool)GetValue(IsToDoSelectProperty); }
            set { SetValue(IsToDoSelectProperty, value); }
        }

        public static readonly DependencyProperty IsToDoSelectProperty =
            DependencyProperty.Register("IsToDoSelect", typeof(bool), typeof(ImageButtonSelect), new PropertyMetadata(true));


        #endregion

        #region IsBtSelected
        /// <summary>
        /// 按钮是否被选中
        /// </summary>
        public bool IsBtSelected
        {
            get { return (bool)GetValue(IsBtSelectedProperty); }
            set { SetValue(IsBtSelectedProperty, value); }
        }
        public static readonly DependencyProperty IsBtSelectedProperty =
            DependencyProperty.Register("IsBtSelected", typeof(bool), typeof(ImageButtonSelect), new PropertyMetadata(false));
        #endregion

        #region DisplayText

        /// <summary>
        /// 获取或设置显示的文本
        /// </summary>
        public string DisplayText
        {
            get { return (string)GetValue(DisplayTextProperty); }
            set { SetValue(DisplayTextProperty, value); }
        }

        public static readonly DependencyProperty DisplayTextProperty =
            DependencyProperty.Register("DisplayText", typeof(string), typeof(ImageButtonSelect), new PropertyMetadata(null));

        #endregion


        #region DisplayText

        /// <summary>
        /// 图片高度
        /// </summary>
        public double ImageHeight
        {
            get { return (double)GetValue(ImageHeightProperty); }
            set { SetValue(ImageHeightProperty, value); }
        }

        public static readonly DependencyProperty ImageHeightProperty =
            DependencyProperty.Register("ImageHeight", typeof(double), typeof(ImageButtonSelect), new PropertyMetadata(double.NaN));

        #endregion
    }
}
